home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d7 / commdrvr.arc / RS232.DOC < prev    next >
Text File  |  1988-04-11  |  12KB  |  290 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.                           RS232 Communications Driver
  22.                                   Version 2.52
  23.  
  24.                                   Introduction
  25.  
  26.   The purpose of this package is to provide RS232 communications support
  27. in device driver form for both the IBM PC and the Texas Instruments
  28. Professional Computer. All machine dependent code is confined to the device
  29. drivers, so communication programs may be developed that run on either
  30. machine. In addition, the programs may run on any other MS-DOS (2.xx or
  31. greater) machine provided a new device driver is written for that machine.
  32. Communications programs are by nature heavily machine dependent and therefore
  33. are normally not portable to any other machine. There have been some attempts
  34. in the past to use the standard device handle "AUX" to write portable
  35. communications packages. However, the default device drivers for many machines
  36. are inadequate in several areas. The device drivers in this package use the
  37. MS-DOS I/O control channel to configure the driver and to check or change the
  38. modem RS232 signals. Some of the features of the drivers used here that make
  39. them useful for communications are:
  40.  
  41.         o Interrupt driven communications
  42.         o Optional flow control
  43.         o Access to the modem signals
  44.         o Ability to change communication settings without disconnecting
  45.         o Ability to force a disconnect by dropping RTS and DTR
  46.         o Option to echo RS232 I/O to the CRT
  47.         o Option to use both the keyboard and the RS232 port as input
  48.         o 110 - 19200 baud rates
  49.         o EVEN, ODD, or no parity using 7 or 8 data bits
  50.         o Device driver is configured using standard MS-DOS function calls
  51.         o Access the number of characters in the receive queue
  52.         o Ability to purge the receive queue
  53.  
  54.   These drivers support all the major needs of any communications program,
  55. and are a substantial improvement over most of the default device drivers
  56. that come standard with each MS-DOS computer.
  57.  
  58.   Using these drivers, any language that can write to the device "AUX" can
  59. now do interrupt driven RS232 I/O. If the language is not capable of issuing
  60. the MS-DOS functions call 44 hex (I/O control) to configure the driver, the
  61. assembly program RS232 is provided to set up the port, baud rate, parity,
  62. etc. for the device driver. The source code for this program is provided as
  63. an example of using the MS-DOS I/O control function call. In addition, a
  64. sample TTY program is included as an example. Here's a list of the files
  65. in this package with a brief description of each file:
  66.  
  67.         IBMRS232.ASM    Source for IBM PC machine dependent code
  68.         IBMRS232.SYS    IBM PC RS232 device driver
  69.         RS232.ASM       Source for RS232 configuration program
  70.         RS232.COM       RS232 config program
  71.         RS232.DOC       Documentation for this package
  72.         RS232.INC       Source for general device driver routines
  73.         TIRS232.ASM     Source for TI PC machine dependent code
  74.         TIRS232.SYS     TI PC RS232 device driver
  75.         TTY.ASM         Source for sample communications program
  76.         TTY.COM         Sample communications program
  77.  
  78.  
  79.                           Installing the Device Driver
  80.  
  81.   Installing the device driver of your choice is done by editing your
  82. CONFIG.SYS file and putting a copy of the driver in your root directory.
  83. As an example, to install the IBM driver on drive C:, first copy the file
  84. IBMRS232.SYS to C:\IBMRS232.SYS. Next, add the following statement to your
  85. C:\CONFIG.SYS file:
  86.  
  87.   DEVICE = IBMRS232.SYS
  88.  
  89. The next time you reboot, the driver will be installed and will take the
  90. device name "AUX". The driver will not respond until you configure it by
  91. writing the Device Configuration Word (DCW) to the I/O control channel.
  92. This is accomplished using the MS-DOS function call 44h (hex) and is covered
  93. in the next section.
  94.  
  95.                       Using the I/O Control Function Call
  96.  
  97.   All I/O control to the device driver is done in one or two byte forms.
  98. The two byte form is used to set up the communications paramenters. The
  99. single byte form is used to select all other options such as checking the
  100. modem signals. We'll cover the single byte form first. Reading one byte
  101. from the I/O control channel causes the driver return the current modem
  102. signals and I/O configuration. (See function 44h, AL=2 in your MS-DOS manual)
  103. The modem signals and options are encoded as follows:
  104.  
  105.              Bit number
  106.   +-------------------------------+
  107.   | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
  108.   |-------------------------------|
  109.   | KI| EI| EO| RI|SCF|DSR|CTS|DCD|
  110.   +-------------------------------+
  111.  
  112.   Bit   Description
  113.    7    0 = RS232 only is used for input.
  114.         1 = Keyboard and RS232 are used for input simultaneously.
  115.  
  116.    6    0 = RS232 input is not echoed to the console display.
  117.         1 = RS232 input is echoed to the console display.
  118.  
  119.    5    0 = RS232 output is not echoed to the console display.
  120.         1 = RS232 output is echoed to the console display.
  121.  
  122.    4    0 = RI (Ring Indicator) is down.
  123.         1 = RI (Ring Indicator) is up.
  124.  
  125.    3    0 = SCF (High speed line) is down.
  126.         1 = SCF (High speed line) is up.
  127.           * The signal SCF is not supported by the IBM PC.
  128.             For the IBM PC, this signal will always be down (0).
  129.  
  130.    2    0 = DSR (Data Set Ready) is down.
  131.         1 = DSR (Data Set Ready) is up.
  132.  
  133.    1    0 = CTS (Clear to Send) is down.
  134.         1 = CTS (Clear to Send) is up.
  135.  
  136.    0    0 = DCD (Data Carrier Detect) is down.
  137.         1 = DCD (Data Carrier Detect) is up.
  138.  
  139.  
  140.   Writing a single byte to the I/O control channel (function 44h, AL=3)
  141. is used to set the driver options, flush the receive buffer, and disconnect
  142. (by dropping RTS and DTR). Below is a chart showing the various values for
  143. the byte code and the action taken:
  144.  
  145.              Bit number
  146.   +-------------------------------+
  147.   | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
  148.   |-------------------------------|
  149.   | KI| EI| EO|   |   |LEN|FIB|DTR|
  150.   +-------------------------------+
  151.  
  152. Name    Bit     Description
  153. KI       7      0 = RS232 only is used for input.
  154.                 1 = Keyboard and RS232 are used for input simultaneously.
  155.  
  156. EI       6      0 = RS232 input is not echoed to the console display.
  157.                 1 = RS232 input is echoed to the console display.
  158.  
  159. EO       5      0 = RS232 output is not echoed to the console display.
  160.                 1 = RS232 output is echoed to the console display.
  161.  
  162.          4      Reserved
  163.  
  164.          3      Reserved
  165.  
  166. LEN      2      0 = Output DCW on 2 byte I/O channel reads. (Default)
  167.                 1 = Output receive queue length on 2 byte I/O channel reads.
  168.                   * Note that this field need only be set once. The current
  169.                     state is used until LEN is changed again.
  170.  
  171. FIB      1      0 = Don't flush receive buffer
  172.                 1 = Flush receive buffer
  173.  
  174. DTR      0      0 = Disconnect (drop DTR and RTS) and reset driver.
  175.                 1 = DTR and RTS up.
  176.  
  177.  
  178.  
  179.  
  180.   The two byte form of I/O control can be used to read or write the
  181. communications settings. Writing a 2 byte value to the control channel
  182. will set the Device Configuration Word (DCW). Reading 2 bytes from the
  183. control channel will do one of two things depending on the state of the
  184. LEN bit. (The LEN bit is set by the user in the single byte control channel
  185. write.) If LEN = 0, the DCW will be read. If LEN = 1, the receive buffer
  186. length is read. The default mode is LEN = 0, read the DCW. Below is a bit
  187. map showing the various fields within the Device Control Word:
  188.  
  189.  +-------------------------------+-------------------------------+
  190.  |           Upper Byte          |           Lower Byte          |
  191.  +-------------------------------+-------------------------------+
  192.  | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
  193.  +-------------------------------+-------------------------------+
  194.  | 1 | 2 | 0 | 3 | 3 | 0 | 4 | 4 | 5 | 5 | 5 | 5 | 6 | 7 | 8 | 8 |
  195.  +-------------------------------+-------------------------------+
  196.  |                           Bit Codes                           |
  197.  +-------------------------------+-------------------------------+
  198.  
  199.         Bit Code        Description
  200.            0            Unused but reserved for future use.
  201.  
  202.            1            Port type
  203.                           0 = parallel (not supported by this driver)
  204.                           1 = serial
  205.  
  206.            2            Number of data bits
  207.                           0 = 7 data bits
  208.                           1 = 8 data bits
  209.  
  210.            3            Port Number
  211.                           00 = Port 1
  212.                           01 = Port 2
  213.                           10 = Port 3  (Port 1 on IBM PC)
  214.                           11 = Port 4  (Port 2 on IBM PC)
  215.  
  216.            4            Flow Control
  217.                           00 = none
  218.                           01 = SCF     (NONE for IBM PC)
  219.                           10 = DSR
  220.                           11 = XON-XOFF
  221.  
  222.            5            Baud Rate
  223.                           0000 = 110
  224.                           0001 = 150
  225.                           0010 = 300
  226.                           0011 = 600
  227.                           0100 = 1200
  228.                           0101 = 2400
  229.                           0110 = 4800
  230.                           0111 = 9600
  231.                           1000 = 19200
  232.  
  233.            6            Number of Stop Bits
  234.                           0 = 1
  235.                           1 = 2
  236.  
  237.            7            Internal Modem
  238.                           0 = No TI internal modem
  239.                           1 = Use TI internal modem
  240.                             * This field must be 0 for the IBM PC
  241.  
  242.  
  243.            8            Parity
  244.                           00 = none
  245.                           01 = ODD
  246.                           10 = none
  247.                           11 = EVEN
  248.  
  249.                               Writing a New Driver
  250.  
  251.   Additional RS232 drivers may be written for other MS-DOS (2.xx and greater)
  252. machines by changing the machine dependent portion of the driver. The two
  253. drivers provided here have their machine dependent code in IBMRS232.ASM and
  254. TIRS232.ASM. The file RS232.INC is an include file and provides the general
  255. device driver functions. Any general changes to the driver should be made
  256. here. To make a new driver, only the machine dependent portion needs to be
  257. written, and any new driver should also use the INCLUDE directive to add the
  258. code from RS232.INC. Following this form will make maintaining the various
  259. drivers much easier.
  260.  
  261.                                 Some Final Notes
  262.  
  263. It should be noted that the TI multifunction card clock driver has a bug in
  264. it that makes TIRS232 lock up. There is a patch floating around for the
  265. multifunction card clock that corrects this problem.
  266.  
  267.   Version 2.52 represents a change in the IBM driver only. Bill Hinkle of
  268. COMTEC Incorporated found and fixed a bug that prevented the user from
  269. changing the baud rate. Many thanks to Bill for reporting the bug.
  270.  
  271.   I would like to see as many machines as possible supported by this driver.
  272. It is my goal to see serial communications for MS-DOS machines standardized.
  273. If you add any machines, I would appreciate a copy of the machine dependent
  274. portion of the driver so I may add it to this package. If you have any
  275. questions about this package or suggestions for later versions, I may be
  276. contacted at the address below:
  277.  
  278.                                    Greg Haley
  279.                                Texas Instruments
  280.                              P.O. Box 405 M/S 3454
  281.                               Lewisville, TX 75067
  282.  
  283.   Happy coding,
  284.    Greg Haley
  285.  
  286.  
  287. MS is a registered trademark of Microsoft Corporation.
  288. IBM is a registered trademark of International Business Machines Corporation.
  289.  
  290.